# Reference: <https://postmarketos.org/vendorkernel>
# Maintainer: Anri Dellal <anridellal@gmail.com>
# Kernel config based on: arch/arm/configs/sp7715ga-native_defconfig

pkgname=linux-nobby-230
pkgver=3.10.17
pkgrel=6
pkgdesc="Nobby 230 kernel fork"
arch="armv7"
_carch="arm"
_flavor="nobby-230"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="gcc4 perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev"

# Compiler: GCC4. Doesn't boot with newer versions of GCC
if [ "${CC:0:5}" != "gcc4-" ]; then
	CC="gcc4-$CC"
	HOSTCC="gcc4-gcc"
	CROSS_COMPILE="gcc4-$CROSS_COMPILE"
fi

# Source
_repository="android_kernel_scx15_sp7715ga_FS001"
_commit="161c7229a4873ead08fc0118d93967b66e38d645"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/Qiangong2/$_repository/archive/$_commit.tar.gz
	$_config
	lcd_ili9340.c::https://raw.githubusercontent.com/HenriDellal/generic-kernels-code/6fb20b61d99c554fed45397b8f05698ee93ddd85/drivers/video/sprdfb/lcd/lcd_nv3029g-01-as-ili9340.c
	kernel-use-the-gnu89-standard-explicitly.patch
	01-fix-X11.patch
	02-arm-eabi-not-found.patch
	03-add-ili9340-support.patch
	04-add-keypad-support.patch
	05-add-xt-dscp-mask-define.patch
	06-set-BGR565-color-mode.patch
"
builddir="$srcdir/$_repository-$_commit"

prepare() {
	default_prepare
	. downstreamkernel_prepare
	cp "$srcdir"/lcd_ili9340.c "$builddir"/drivers/video/sprdfb/lcd/
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"

	make ARCH="$_carch" CC="${CC:-gcc}" CFLAGS_MODULE="-fno-pic" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1))-postmarketOS" modules
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor"

	unset LDFLAGS
	make modules_install \
		ARCH="$_carch" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1))-postmarketOS" \
		INSTALL_MOD_PATH="$pkgdir" INSTALL_MOD_STRIP=1
}

sha512sums="0bee0e9c67c155957ed90f6f3707ec9663fd541c1c73e93c747b71423b37d64486c1c758b5e889280210b69d377c0bb203346f8d290252d5a4989788749b6e89  linux-nobby-230-161c7229a4873ead08fc0118d93967b66e38d645.tar.gz
6af9f401c87dae1c46bea5f7e651408f0b5488589253475585c7eba06d5c09ff44282edaa8219d56b5169e31d9f6bb86b4daf0802a4da420590816cd1f4208a4  config-nobby-230.armv7
35f8b9f5a22c8aec5906b1ba2fc4c214962d8091e933abe7b354b0e9023b03bb543a08157e0d22c68367ef30b3543af9385299fdcfa8df63cca9da08a8fa4d80  lcd_ili9340.c
ad0182a483791fc88e058838bc331b2f04a75ba291e763767babdb815efadfc3b4fda97e69e2e3f00a426cabea088e35297a92bd287592597d1e309be68ee92c  kernel-use-the-gnu89-standard-explicitly.patch
fd3d5578120f43a09013feebe3ea75cff71de1078a92a20d27083f15279106f4c95f7889d432eabc689954d9db4bff09a429374b8d2891f23f08d64e66affd86  01-fix-X11.patch
1cc15cf60c31f9cf4d82c74c3578fd8be55506278e5106634973784179509e47a7741e42241a7aa8622c0ce4192a331cf860b11537998ba4f8af4da13718229e  02-arm-eabi-not-found.patch
9897f8c0f1846bca8be3c7a928c908df69f03c3a833e24c0f0b7aff75fc66b8cbae9b3022acb6182f89e9a1297e5f04d1cf4f03b4f570c808e6cdcac747c4aec  03-add-ili9340-support.patch
7207dfbdf34b658045b7c1d35b65223a88bd469dcd9c98265b62884b336ff5c28f893e259b4655ae2c3e0a1ec3d6db5e018a178c2628641f95bf1282841bbe3d  04-add-keypad-support.patch
8eb858cb1389bc5a9b39be96d8bb76d5ba6d58859eab32a496103d0d70218e994956fdd45e73e58a56881348b07503cdb177ee8836b797772af9d2743d58ed03  05-add-xt-dscp-mask-define.patch
b0b59a222ab44d1c4e90fed0506d38282e8a2dfbed4bde9c0c5e381ae40177d916abec984a2b66fbca9d96c3afe4e3fa0e0922a300e91cb8ac1020cb15a9f88b  06-set-BGR565-color-mode.patch"
